import queue
import threading

# message queue
class MQ:
    def __init__(self, maxsize, div=300):
        self.cond = threading.Condition()
        self.ack = True
        self.flag = 0
        self.div = div
        self.buf_msg = {}
        self.queue = queue.Queue(maxsize=maxsize)

    def get_flag(self):
        with self.cond:
            return self.flag
    
    def add_flag(self):
        with self.cond:
            self.flag = (self.flag + 1) % self.div
        
    def get_ack(self):
        with self.cond:
            return self.ack

    def set_ack(self, ack):
        with self.cond:
            self.ack = ack